<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <!-- ...运算符 将数组转为【参数序列】 -->
    <script>
        //const 常量（值不能被修改的变量叫做常量）
        //const 潜规则 声明形势除了声明的类型函数（fn）外 必须全部大写
        const SCHOOL = 'kw06';
        /*
          const 不能被修改 ---可以修改对象里面或者数组里面的值
          const 也是拥有块级作用域的
        */
        {
            const BOY = '於光磊';
        }
        // console.log(BOY);
        const ZHANGMING = ['张明', '男人', '穷人'];
        ZHANGMING.push('weihun');
        console.log(ZHUNGMING);

        function laojiang(a, b = 1) {
            console.log((a + b));
        }
        laojiang(1);

        //简化对象写法
        let name = '班长';
        let change = function() {
                console.log('真漂亮');
            }
            // const SCHOOL = {
            //     name,
            //     change
            // };
        const SCHOOL = {
            name,
            change
        };
        console.log(SCHOOL);


        const SCHOOL = {
            name: '渣男培训学校'
        }
        window.name = '123';
        console.log(this);

        function getName() {
            console.log(this.name);
        }
        getName();
        let getName2 = () => {
            console.log(this.name);
        }
        getName2();
        getName.call(SCHOOL);
        getName2.call(SCHOOL);
        /*
          箭头函数开始的时候作用域的this指向某一个位置对象后就不会改变当前的this
          箭头函数不能作为为构造函数实例化对象
          箭头函数参数只有一个的话可以省略 入参左右（）
          箭头函数参数里面只有一句话可以省略大括号{}(如果一句话含有return 那么return 也省略)
        */
        let fn = q => q + q;
        console.log(fn(3));

        //解构
        const DUIXIANG = ['蒋富涛', '有钱', '有老婆'];
        //数组解构
        let [a, b, c] = DUIXIANG;
        console.log(a);
        console.log(b);
        console.log(c);
        //对象解构
        const ZHANG = {
            name: '张明飞',
            age: '999',
            kanren: function() {
                console.log('我张飞会砍人');
            }
        }
        let {
            name,
            age,
            kanren
        } = ZHANG;
        console.log(name, age, kanren);
        kanren();


        const BANZHANG = ['1', '2'];
        console.log(...BANZHANG);
        //应用场景
        const A = ['1', '2'];
        const B = ['3', '4'];
        let C = [...A, ...B];
        console.log(C);
        //深拷贝
        const D = [...A];
        D[0] = '5';
        console.log(D);
        console.log(A);
        //将DOM为数组变成真正意义上的数组
        let divs = document.getElementsByTagName('div');
        console.log(divs);
        const divArr = [...divs];
        console.log(divArr);


        let out = '金语';
        let love = `${out}爱老婆`;
        console.log(love);

        //object.assign()
        //将多个对象的属性和方法都合并到目标对象上
        //格式是（目标对象，后面跟着多个或者一个原对象）
        let target = {} //目标对象
        let name1 = {
            name: 'img',
            age: '123'
        }
        let name2 = {
            sex: '男'
        }
        let name3 = {
            sex: '女'
        }
        Object.assign(target, name1, name2, name3);
        console.log(target);
    </script>
</body>

</html>